package com.buba.system.controller;

import com.buba.system.pojo.Job;
import com.buba.system.service.JobService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/Job")
public class JobController {
    @Autowired
    @Qualifier("jobServiceImpl")
    private JobService jobService;
    @RequestMapping("/selJobAll")
    public Map<String,Object> selJobAll(){
        Map<String,Object> map=new HashMap<>();
        List<Job> list=jobService.selJobAll();
        map.put("list",list);
        return map;
    }

    @RequestMapping("/delJobAll")
    public Map<String,Object> delJobAll(String ids){
        Map<String,Object> map=new HashMap<>();
        String[] split = ids.split(",");
        List<String> list = Arrays.asList(split);
        //删除职位的权限
        Integer count1=jobService.delMenuAll(list);
        //删除职位和员工中间表
        Integer count2=jobService.delJobEmpAll(list);
        //删除职位
        Integer count=jobService.delJobAlll(list);
        if(count!=0){
            map.put("message","删除"+count+"条数据");
        }else{
            map.put("message","删除失败");
        }
        return map;
    }
}
